<template>
	<view class="me">
		<view class="header">
			<view class="avatar">
				<image :src="userInfo.avatar" mode="aspectFill"></image>
				<view class="des">
					<text>{{userInfo.nickname}}</text>
					<text>{{userInfo.mobile}}</text>
				</view>
			</view>
			 <view>------------------</view>
			 <view>会员尊享超值优惠</view>
			</view>
			
			<view class="balance">
				<!-- <view class="item" @click="goIntegral()">
					<text>0</text>
					<text>积分</text>
				</view> -->
				<view class="item">
					<text >{{userInfo.surplus}}</text>
					<text>余额</text>
				</view>
				<view class="item" @click="goCoupons()">
					<text>0</text>
					<text>优惠券</text>
				</view>
				<!-- <view class="item" @click="goGift_cards()">
					<text>0</text>
					<text>礼卡</text>
				</view> -->
			</view>
			
			<view class="order">
				<text>我的订单</text>
				<text>查看我的订单</text>
			</view>
			
			<view class="pay">
				<view class="item" @click="goMyorder(0)">
					<image src="../../static/icon/daifukuan.png" ></image>
					<text>待付款</text>
				</view>
				<view class="item" @click="goMyorder(1)">
					<image src="../../static/icon/daifahuo.png"></image>
					<text>待发货</text>
				</view>
				<view class="item" @click="goMyorder(2)">
					<image src="../../static/icon/daishouhuo2.png"></image>
					<text>待收货</text>
				</view>
				<view class="item">
					<image src="../../static/icon/daiziti.png" style="color: black"></image>
					<text>待自提</text>
				</view>
				<view class="item">
					<image src="../../static/icon/huaban24.png"></image>
					<text>退款记录</text>
				</view>
			</view>
			
			 <view class="foot">
				<view class="item" @click="goaddress()">
					<text>地址管理</text>
					<text>></text>
				</view>
				<view class="item" @click="goOpinion()">
					<text>意见反馈</text>
					<text>></text>
				</view>
				<view class="item" @click="goinfo()">
					<text >个人信息</text>
					<text>></text>
				</view>
				<view class="item" @click="gologout()">
					<text>退出登录</text>
					<text>></text>
				</view>
			 </view>
		
	</view>
</template>

<script>
	const CloudUser=uniCloud.importObject("users")
	export default {
		data() {
			return {
				userInfo:""
			};
		},
		onShow() {
			this.getuserInfo(uni.getStorageSync("uni-id-pages-userInfo")._id);
		},
		methods:{
			getuserInfo(user_id){
				CloudUser.getuserInfo(user_id).then(res=>{
					console.log(res);
					this.userInfo=res.data[0];
				})
			},
			goIntegral(){
				uni.navigateTo({
					url:"/pages/integration/integral/integral"
				})
			},
			goGift_cards(){
				uni.navigateTo({
					url:"/pages/integration/gift_cards/gift_cards"
				})
			},
			goCoupons(){
				uni.navigateTo({
					url:"/pages/integration/coupons/coupons"
				})
			},
			goMyorder(current){
				uni.navigateTo({
					url:"/pages/order/myorder/myorder?&current="+current
				})
			},
			goaddress(){
				uni.navigateTo({
					url:"/pages/address/myAddress/myAddress"
				})
			},
			goOpinion(){
				uni.navigateTo({
					url:"/pages/opinion/opinion"
				})
			},
			goinfo(){
				uni.navigateTo({
					url:"/pages/userInfo/userInfo"
				})
			},
				
			gologout(){
				uni.navigateTo({
					url:"/uni_modules/uni-id-pages/pages/login/login-withpwd"
				})
			}
		}
	}
</script>

<style lang="scss">
.header{
	box-sizing: border-box;
	width: var(--status-bar-width);
	height: 300rpx;
	// background-color: tomato;
	padding:20rpx 50rpx;
	.avatar{
		width: 100%;
		height: 150rpx;
		display: flex;
		image{
			width: 150rpx;
			height: 150rpx;
			border-radius: 50% ;
		}
		.des{
			margin-left: 10rpx;
			display: flex;
			justify-content: space-around;
			flex-direction: column;
			text{
				font-size: 30rpx;
			}
		}
	}
}
.balance{
	    margin-top: 30rpx;
	    box-sizing: border-box;
		padding: 0 50rpx;
		width: var(--status-bar-width);
		height: 120rpx;
		// background-color: green;
		display: flex;
		// justify-content: space-around;
		.item{
			display: flex;
			justify-content: space-around;
			flex-direction: column;
			flex-basis: 200rpx;
		}
	}
.order{
	    box-sizing: border-box;
		width:  var(--status-bar-width);
		height: 80rpx;
		// background-color: blue;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 50rpx;
}
.pay{
	    margin-top: 30rpx;
	    box-sizing: border-box;
		width: var(--status-bar-width);
		height: 120rpx;
		// background-color: green;
		display: flex;
		justify-content: space-around;
		padding: 0 50rpx;
		.item{
			image{
				width: 50rpx;
				height: 50rpx;
			}
			display: flex;
			justify-content: space-around;
			flex-direction: column;
			flex:1
		}
	}
.foot{
	margin-top: 30rpx;
	box-sizing: border-box;
	width: 100%;
	// background-color: crimson;
	padding: 0 50rpx;
	.item{
		height: 100rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		flex:1
	}
}
</style>
